package com.zpark.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zpark.mapper.UserMapper;
import com.zpark.pojo.User;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Title: UserService
 * @Author Charles
 * @Package service
 * @Date 2022/12/6 23:07
 */
@Service
@Slf4j
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public List<User> findAll(){
        // 查询所有
        return userMapper.selectList(new LambdaQueryWrapper<>());
    }
        //分页查询
    public List<User> findPage(int current,int pageSize){
        Page<User> page=new Page<>(current,pageSize);

        Page<User> userPage=userMapper.selectPage(page,new LambdaQueryWrapper<>());
        log.info("total:{}",userPage.getTotal());
        log.info("pages:{}",userPage.getPages());
        return userPage.getRecords();
    }



}
